//
//  NewView.m
//  Four_Fit_New
//
//  Created by xalo on 16/7/14.
//  Copyright © 2016年 xmaz. All rights reserved.
//

#import "NewView.h"

@interface NewView ()
{
    CAShapeLayer *shape;
}
@end

@implementation NewView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //三角形
        UIBezierPath *bezier = [[UIBezierPath alloc] init];
        [bezier moveToPoint:CGPointMake(0, 0)];
        [bezier addLineToPoint:CGPointMake(self.frame.size.width, 0)];
        [bezier addLineToPoint:CGPointMake(self.frame.size.width, self.frame.size.height)];
        [bezier addLineToPoint:CGPointMake(0, 0)];
        shape = [[CAShapeLayer alloc] init];
        shape.path = bezier.CGPath;
        shape.fillColor = [UIColor colorWithRed:1.00 green:0.76 blue:0.24 alpha:1.00].CGColor;
        [self.layer addSublayer:shape];
        //文字
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, self.frame.size.height / 6.0 + 3, self.frame.size.width, self.frame.size.height / 3.0 - 3)];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = @"New!";
        label.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:15];
//        NSLog(@"%@",[UIFont fontNamesForFamilyName:@"Helvetica Neue"]);
        label.textColor = [UIColor whiteColor];
        label.transform = CGAffineTransformMakeRotation(M_PI/4.0);
        [self addSubview:label];
    }
    return self;
}
@end
